package com.software.seakdream.controller;

import com.software.seakdream.domain.Result;
import com.software.seakdream.entity.Favorite;
import com.software.seakdream.entity.History;
import com.software.seakdream.service.FavoriteService;
import com.software.seakdream.service.HistoryService;
import com.software.seakdream.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Favorite")
public class FavoriteController {
    @Autowired
    private FavoriteService favoriteService;

    @PostMapping("/createFavorite")
    public Result createFavorite(Favorite favorite){
        Favorite create = favoriteService.createFavorite(favorite);
        return ResultUtils.success(create);
    }

    @PostMapping("/createFavoriteW")
    public Result createFavoriteW(Favorite favorite){
        Favorite create = favoriteService.createFavoriteW(favorite);
        return ResultUtils.success(create);
    }

    @GetMapping("/deleteFavorite")
    public Result deleteFavorite(String userId, String audioId){
        Boolean delete = favoriteService.deleteFavorite(userId, audioId);
        if (delete){
            return ResultUtils.success("成功删除");
        }else {
            return ResultUtils.error("404", "无法删除", "删除失败");
        }
    }

    @GetMapping("/deleteFavoriteW")
    public Result deleteFavoriteW(String userId, String whiteId1){
        Boolean delete = favoriteService.deleteFavoriteW(userId, whiteId1);
        if (delete){
            return ResultUtils.success("成功删除");
        }else {
            return ResultUtils.error("404", "无法删除", "删除失败");
        }
    }
}
